<html class="popupwin">
<!--
/***************************************************************
*  Copyright notice
*
*  (c) 2004 Cau guanabara <caugb@ibest.com.br>
*  (c) 2005-2009 Stanislas Rolland <typo3(arobas)sjbr.ca>
*  All rights reserved
*
*  This script is part of the TYPO3 project. The TYPO3 project is
*  free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 2 of the License, or
*  (at your option) any later version.
*
*  The GNU General Public License can be found at
*  http://www.gnu.org/copyleft/gpl.html.
*  A copy is found in the textfile GPL.txt and important notices to the license
*  from the author is found in LICENSE.txt distributed with these scripts.
*
*
*  This script is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  This script is a modified version of a script published under the htmlArea License.
*  A copy of the htmlArea License may be found in the textfile HTMLAREA_LICENSE.txt.
*
*  This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/*
 * Find and Replace Plugin for TYPO3 htmlArea RTE
 *
 * TYPO3 SVN ID: $Id: find_replace.html 5037 2009-02-19 18:36:11Z stan $
 */
-->
<head>
	<title>Find and Replace</title>
	<meta http-equiv="Content-Style-Type" content="text/css" />
	<script type="text/javascript" src="../fr_engine.js"></script>
	<script type="text/javascript">
		/*<![CDATA[*/
		<!--
		var dialog = window.opener.HTMLArea.Dialog.FindReplace;
		var editor;
		var accepted = {
			'fr_pattern'       : true,
			'fr_replacement'   : true,
			'fr_words'         : true,
			'fr_matchcase'     : true,
			'fr_replaceall'    : true
		};

		function Init() {
			editor = dialog.plugin.editor;
			disable("fr_undo,fr_clear,fr_hiliteall", true);

			var params = dialog.arguments;
			if (params) {
				document.getElementById('fr_pattern').value = params.fr_pattern;
				document.getElementById('fr_replacement').focus();
			} else {
				document.getElementById('fr_pattern').focus();
			}
			window.opener.HTMLArea._addEvent(document, "keypress", onKeyPress);
			if (window.opener.HTMLArea.is_gecko) {
				window.opener.HTMLArea._addEvent(window, "unload", onCancel);
			}
			dialog.initialize();
			if (HTMLArea.is_ie) {
				HTMLArea._addEvent(window, "unload", onCancel);
			}
		};
		function requestReplacement() {
			if (!document.getElementById("fr_replacement").value && document.getElementById("fr_replaceall").checked) {
				return confirm(dialog.plugin.localize("Inform a replacement word"));
			}
			clearDoc();
		}
		function onCancel() {
			if (dialog) {
				clearDoc();
				HTMLArea._removeEvent(document, "keypress", onKeyPress);
				HTMLArea._removeEvent(window, "unload", onCancel);
				dialog.close();
			}
			return false;
		};
		function onOK() {
			var required = {'fr_pattern' : dialog.plugin.localize("Enter the text you want to find")};
			for (var i in required) {
				var el = document.getElementById(i);
				if (!el.value) {
					alert(required[i]);
					el.focus();
					return false;
				}
			}

			var param = {};
			for (var i in accepted) {
				var el = document.getElementById(i);
				param[i] = (el.type == "checkbox") ? el.checked : el.value;
			}
			execSearch(param);
			return false;
		};
		function onEscape(ev) {
			if (!ev) var ev = window.event;
			if (ev.keyCode == 27) {
				return onCancel();
			}
			return true;
		};
		function onKeyPress(ev) {
			if (!ev) var ev = window.event;
			switch(ev.keyCode) {
				case 13:
					document.getElementById('fr_go').click();
					document.getElementById('fr_pattern').focus();
					break;
				case 27:
					return onCancel();
			}
			return true;
		};
		// -->
		/*]]>*/
	</script>
</head>
<body class="popupwin" onload="Init();">
<div id="content">
<div class="title">Find and Replace</div>
<form action="" method="get">
	<dl>
		<dt>
			<label for="fr_pattern" class="field">Search for:</label>
		</dt>
		<dd>
			<input id="fr_pattern" type="text" size="35" onFocus="this.select();">
		</dd>
		<dt>
			<label for="fr_replacement" class="field">Replace with:</label>
		</dt>
		<dd>
			<input id="fr_replacement" type="text" size="35" onFocus="this.select();">
		</dd>
	</dl>
	<fieldset>
		<legend>Options</legend>
		<ul>
			<li>
				<input id="fr_words" type="checkbox" checked onClick="clearDoc();">
				<label for="fr_words" class="long-label">Whole words only</label>
			</li>
			<li>
				<input id="fr_matchcase" type="checkbox" onClick="clearDoc();">
				<label for="fr_matchcase" class="long-label">Case sensitive search</label>
			</li>
			<li>
				<input id="fr_replaceall" type="checkbox" onClick="requestReplacement();">
				<label for="fr_replaceall" class="long-label">Substitute all occurrences</label>
			</li>
		</ul>
	</fieldset>
	<fieldset>
		<legend>Actions</legend>
		<ul>
			<li>
				<button type="button" class="long-button" id="fr_clear" onClick="clearMarks();">Clear</button>
			</li>
			<li>
				<button type="button" class="long-button" id="fr_hiliteall" onClick="hiliteAll();">Highlight</button>
			</li>
			<li>
				<button type="button" class="long-button" id="fr_undo" onClick="resetContents();">Undo</button>
			</li>
		</ul>
	</fieldset>
	<div class="space"></div>
	<div class="buttons">
		<button type="button" id="fr_go" onclick="return onOK();">Next</button>
		<button type="button" name="cancel" onclick="return onCancel();">Done</button>
	</div>
</form>
</div>
</body>
</html>
